﻿//-----------------------------------------------------------------------
// <copyright file="NewsStory.cs" company="Microsoft Corporation">
//     Copyright Microsoft Corporation. All Rights Reserved. This code released under the terms of the Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.) This is sample code only, do not use in production environments.
// </copyright>
//-----------------------------------------------------------------------

namespace Microsoft.ALMRangers.VsarTreasureMap.WindowsStoreApp.News
{
    using System;
    using System.Globalization;

    /// <summary>
    /// Defines a new item for RSS feed &amp; tiles.
    /// </summary>
    public class NewsStory
    {
        /// <summary>
        /// Gets or sets the id.
        /// </summary>
        /// <value>The id.</value>
        public string Id { get; set; }

        /// <summary>
        /// Gets or sets the title.
        /// </summary>
        /// <value>The title.</value>
        public string Title { get; set; }

        /// <summary>
        /// Gets or sets the author.
        /// </summary>
        /// <value>The author.</value>
        public string Author { get; set; }

        /// <summary>
        /// Gets or sets the content.
        /// </summary>
        /// <value>The content.</value>
        public string Content { get; set; }

        /// <summary>
        /// Gets or sets the published.
        /// </summary>
        /// <value>The published.</value>
        public DateTime Published { get; set; }

        /// <summary>
        /// Gets the age.
        /// </summary>
        /// <value>The age.</value>
        public string Age
        {
            get
            {
                var difference = DateTime.Now.Subtract(this.Published);
                if (difference.TotalHours < 49)
                {
                    return string.Format(CultureInfo.CurrentUICulture, "{0} hours ago", (int)Math.Floor(difference.TotalHours));
                }

                return string.Format(CultureInfo.CurrentUICulture, "{0} days ago", (int)Math.Floor(difference.TotalDays));
            }
        }

        /// <summary>
        /// Gets or sets the link.
        /// </summary>
        /// <value>The link.</value>
        public Uri Link { get; set; }
    }
}
